package servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

/**
 * 05-ServletContext对象
 * ③获取资源在服务器上的真实磁盘路径(部署路径)
 *
 */
public class Demo06Servlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String admin = getServletContext().getInitParameter("admin");
        System.out.println("admin = " + admin);

        Enumeration<String> initParameterNames = getServletContext().getInitParameterNames();
        while (initParameterNames.hasMoreElements()) {
            String parameterName = initParameterNames.nextElement();
            String parameterValue = getServletContext().getInitParameter(parameterName);
            System.out.println("parameterValue = " + parameterValue + " , parameterName = " + parameterName);

        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
